home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / tool_inc.zip / BITMAP.INC < prev    next >
Text File  |  1989-06-02  |  1KB  |  45 lines

  1.  
  2. (*
  3.  * Copyright 1987, 1989 Samuel H. Smith;  All rights reserved
  4.  *
  5.  * This is a component of the ProDoor System.
  6.  * Do not distribute modified versions without my permission.
  7.  * Do not remove or alter this notice or any other copyright notice.
  8.  * If you use this in your own program you must distribute source code.
  9.  * Do not use any of this in a commercial product.
  10.  *
  11.  *)
  12.  
  13. (*
  14.  * bitmap.inc - Library to BitMap manipulation functions
  15.  *
  16.  *)
  17.  
  18. (* --------------------------------------------------------- *)
  19. function getbit(map: bitmap; bitnum: bitnumber): boolean;
  20.    {return true/false for specified bit 0..39 in a bitmap}
  21. var
  22.    byteno:  integer;
  23.    bitno:   integer;
  24. begin
  25.    byteno := bitnum shr 3;    {0..4}
  26.    bitno  := bitnum mod 8;    {0..7}
  27.    getbit := odd(map.bits[byteno] shr bitno);
  28. end;
  29.  
  30. (* --------------------------------------------------------- *)
  31. procedure setbit(var map: bitmap; bitnum: bitnumber; value: boolean);
  32.    {set the specified bit in a bitmap}
  33. var
  34.    byteno:  integer;
  35.    bitno:   integer;
  36. begin
  37.    byteno := bitnum shr 3;    {0..4}
  38.    bitno  := bitnum mod 8;    {0..7}
  39.    if value then
  40.       map.bits[byteno] := map.bits[byteno] or (1 shl bitno)
  41.    else
  42.       map.bits[byteno] := map.bits[byteno] and (255 - (1 shl bitno));
  43. end;
  44.  
  45.